package com.yiyi.credit.manage.abutment.mapper;

import com.yiyi.credit.manage.abutment.common.mapper.CommonMapper;
import com.yiyi.credit.manage.model.entity.ProjectAmountWater;
import com.yiyi.credit.manage.model.entity.ProjectToThird;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;


public interface ProjectToThirdMapper extends CommonMapper<ProjectToThird> {

    @Select("SELECT pt.* from project_info p INNER JOIN project_to_third pt ON p.id = pt.prCode INNER JOIN third_party t ON t.id = pt.tCode " +
            " where p.accountNumber=#{accountNumber} and t.account=#{account} ")
    ProjectToThird selectProjectToThird(@Param("accountNumber") String accountNumber, @Param("account") String account);

    @Update("update project_to_third set cost = cost + #{amount} ,updateTime = NOW() where id = #{id}")
    int updateProjectToThird(@Param("amount")BigDecimal amount,@Param("id")String id);
}